Use case: DCACHE maintenance in polling mode with error interrupt enabled ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
/* Enable error interrupt */
HAL_DCACHE_RegisterCallback(&hdcache, HAL_DCACHE_ERROR_CB_ID,
USER_DCACHE_ErrorCallback);
HAL_DCACHE_Enable(&hdcache);
__HAL_DCACHE_ENABLE_IT(&hdcache, DCACHE_IT_ERR);
/* Run a maintenance operation */
(void)HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
/* In IRQ handler */
void DCACHE_IRQHandler(void)
{
HAL_DCACHE_IRQHandler(&hdcache);
}
|
/* Enable error interrupt */
HAL_DCACHE_RegisterErrorCallback(myDCACHE_ErrorCallback);
HAL_DCACHE_Start(&hdcache, HAL_DCACHE_IT_ERROR);
/* Run a maintenance operation */
(void)HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
/* In IRQ handler */
void DCACHE_IRQHandler(void)
{
HAL_DCACHE_IRQHandler(&hdcache);
}
|
Key changes ¶
HAL2 uses
HAL_DCACHE_RegisterErrorCallback()instead of registering by callback ID.HAL2 enables error interrupts via
HAL_DCACHE_Start().The cache maintenance call remains
HAL_DCACHE_CleanByAddr().
![@startuml
participant "User\nApplication" as UA order 1
participant "DCACHE\nDriver" as DD order 2
participant "DCACHE_IRQHandler" as IRQ order 3
skinparam sequenceMessageAlign center
== DCACHE Initialization ==
group Option [USE_HAL_DCACHE_REGISTER_CALLBACKS]
UA -> DD : **HAL_DCACHE_RegisterCallback**(&hdcache, HAL_DCACHE_ERROR_CB_ID, USER_DCACHE_ErrorCallback)
DD --> UA : return HAL_OK
end
UA -> DD : **HAL_DCACHE_Enable**
DD --> UA : return HAL_OK
UA -> DD : **__HAL_DCACHE_ENABLE_IT**
rnote over DD
Enable ERROR Interrupt
endrnote
|||
UA-[#blue]>DD : **HAL_DCACHE_CleanByAddr**
activate DD #blue
note over DD : Check Busy flag : Flag = 0
IRQ <[#orange]- : DCACHE Error interrupt
IRQ -[#orange]> DD : **HAL_DCACHE_IRQHandler**
activate DD #orange
note over DD : Flag Error Interrupt = 1
alt USE_HAL_DCACHE_REGISTER_CALLBACKS
DD -[#orange]> UA : **USER_DCACHE_ErrorCallback**
UA -[#orange]-> DD
else USE OVERRIDDEN WEAK CALLBACKS
DD -[#orange]> UA : **HAL_DCACHE_ErrorCallback**
UA -[#orange]-> DD
end
deactivate DD
DD -[#blue]-> UA : return HAL_OK
deactivate DD
|||
rnote over UA
The user can call __HAL_DCACHE_DISABLE_IT() to disable the Error Interrupt
and call HAL_DCACHE_Disable() to stop the DCACHE or make an other action.
endrnote
@enduml](../../../../../_images/plantuml-5a17bd7872e929696aa082e6217c843b041eaee5.png)
![@startuml
participant "User\nApplication" as UA order 1
participant "DCACHE\nDriver" as DD order 2
participant "DCACHE_IRQHandler" as IRQ order 3
skinparam sequenceMessageAlign center
== DCACHE Initialization ==
group Option [USE_HAL_DCACHE_REGISTER_CALLBACKS]
UA -> DD : **HAL_DCACHE_RegisterErrorCallback**(myDCACHE_ErrorCallback)
DD --> UA : return HAL_OK
end
UA -> DD : **HAL_DCACHE_Start**(HAL_DCACHE_IT_ERROR)
rnote over DD
Enable ERROR Interrupt
endrnote
DD --> UA : return HAL_OK
|||
UA-[#blue]>DD : **HAL_DCACHE_CleanByAddr**
activate DD #blue
note over DD : Check Busy flag : Flag = 0
IRQ <[#orange]- : DCACHE Error interrupt
IRQ -[#orange]> DD : **HAL_DCACHE_IRQHandler**
activate DD #orange
note over DD : Flag Error Interrupt = 1
alt USE_HAL_DCACHE_REGISTER_CALLBACKS
DD -[#orange]> UA : **myDCACHE_ErrorCallback**
UA -[#orange]-> DD
else USE OVERRIDDEN WEAK CALLBACKS
DD -[#orange]> UA : **HAL_DCACHE_ErrorCallback**
UA -[#orange]-> DD
end
deactivate DD
DD -[#blue]-> UA : return HAL_OK
deactivate DD
|||
rnote over UA
The user can call HAL_DCACHE_Stop() to disable the Error Interrupt
and stop the DCACHE or make an other action.
endrnote
@enduml](../../../../../_images/plantuml-5cf7413ba627d193ef55b0fa392e5796b688c649.png)